/*
 * Copyright 2012 Gayan Perera
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package gap.maven.script.components.api;


/**
 * The script context which will be used to lookup various components and maven project if one exist.
 * The context instance can be take by calling  binding.getVariable("context") in the script code. 
 * @author gayan
 */
public interface ScriptContext {

    /**
     * Use {@link ArtifactFileFactory#SCRIPT_CONTEXT_KEY} instead of this.
     */
    @Deprecated
    public static final String ARTIFACT_FILE_FACTORY_KEY = "gap.maven.script.components.api.ArtifactFileFactory";
 
    /**
     * Lookup components by passing the key of the component.
     * @param key The component SCRIPT_CONTEXT_KEY which is defined in the component API interface.
     * @return The instance of the requested component if it is initiated. Else returns null.
     */
    <T> T lookup(String key);

    /**
     * Returns the project pom as a {@link POMArtifactFile}. Calling this method when there is no maven project will
     * cause a {@link IllegalStateException} to be thrown.
     * @return instance of {@link POMArtifactFile}.
     */
    POMArtifactFile getProject();

    /**
     * Checks whether there is a maven project pom available.
     * @return <code>true</code> if there is a project pom.
     */
    boolean hasProjectPOM();

}
